[v12] Ensure that the webclient closes connections#22893
Merged
rosstimothy merged 1 commit intobranch/v12from Mar 10, 2023
Merged
[v12] Ensure that the webclient closes connections#22893rosstimothy merged 1 commit intobranch/v12from
webclient closes connections#22893rosstimothy merged 1 commit intobranch/v12from
Conversation
marcoandredinis
approved these changes
Mar 10, 2023
The `http.Client.Transport` created in `newWebClient` wraps a chain of `http.RoundTripper` over an underlying `http.Transport`. Since we cannot guarantee that each `http.RoundTipper` has a `CloseIdleConnections` method the usage of `defer clt.CloseIdleConnections()` does not guarantee that the http connections created during Find/Ping/etc are closed. To prevent leaking connections implementations of `http.RoundTripper` have added a `CloseIdleConnections` method added that forwards the request on to the wrapped interface. The `otelhttp.Transport` does not implement this method either so care has been taken to wrap it in a `http.RoundTripper` which will call the root transport in `enforceCloseIdleConnections`. An upstream issue has been filed with otelhttp: open-telemetry/opentelemetry-go-contrib#3543 to get the method added to their `Transport` implementation. This wasn't noticed prior to upgrading to go1.20 becuase prior to [this](golang/go@4e7e7ae) commit the `ReadHeaderTimeout` set on the Proxy web api http.Server would cause the connection to appear idle and get terminated by the server. `TestWebClientClosesIdleConnections` was added to capture the leak in connections as reported in #22757 and prevent any regressions.
cb7f13d to
0f3f787
Compare
zmb3
approved these changes
Mar 10, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport #22832 to branch/v12